/*
 * Copyright 2010 Torokina Networks Pty Ltd
 */

package habi.cat.youdao.supermemo;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.Writer;
import java.util.List;

/**
 *
 * @author Jeff Huang (jeff.huang@ca.com)
 */
public class SuperMemoSaver {

    public void save1(Writer writer, List<YouDaoWordItem> items) {
        PrintWriter pw = new PrintWriter(writer);
        for(YouDaoWordItem item : items) {
            pw.printf("Q: %s\r\n", item.getWord());
            pw.printf("A: %s\r\n", item.getPhonetic());
            String[] splits = item.getTrans().split("[\\r\\n][\\r\\n]*", -1);
            for(String s : splits) {
                pw.printf("A: %s\r\n", s);
            }
            pw.println();
        }

    }

    public void save2(Writer writer, List<YouDaoWordItem> items) {
        PrintWriter pw = new PrintWriter(writer);
        for(YouDaoWordItem item : items) {
            pw.printf("Q: %s\n", item.getTrans());
            pw.printf("A: %s\n", item.getWord());
            pw.printf("A: %s\n", item.getPhonetic());
            pw.println();
        }
    }

}
